<template>
	<view>
		<view class="flex-jus flex-start">
			<view class="flex1 mr10">
				<view class=" list-item mb20" :class="{'bgFff box_shadow':item.type != 'draft'}"
					v-for="(item,index) in ouList" :key="index">
					<view class="" v-if="item.type == 'draft'" @click="openUrl('/subpage/me/draft')">
						<view class="list-img pore">
							<image :src="api_host + config.avatar" mode="widthFix" class="pro-img">
							</image>
							<view class="draft_box textC flex-au jus-center">
								<view class="">
									<view class="">
										<image src="../../static/images/you/cg_w.png" mode=""
											style="width: 60rpx;height: 60rpx;"></image>
									</view>
									<view class="">
										<text class="cfff f26">本地草稿</text>
									</view>
								</view>
							</view>
						</view>
					</view>
					<view class="" v-else @click="nologinJump('/subpage/travel/workDetail?id='+item.id)">
						<view class="list-img">
							<image :src="api_host + item.coverIcon" class="pro-img" mode="widthFix"></image>
						</view>
						<view class="p20">
							<!-- 遇见黄石 -->
							<view class="flex user-box" v-if="item.relatedColumn === 3">
								<image class="avatar" :src="api_host + item.encounterUser.userAvatar" mode=""></image>
								<text class="f24 c343 ml10 nick-name">{{item.encounterUser.nickName}}</text>
							</view>
							<view class="flex user-box" v-else>
								<image class="avatar" :src="api_host + item.user.userAvatar" mode=""></image>
								<text class="f24 c343 ml10 nick-name">{{item.user.userName}}</text>
							</view>
							<u-gap height="5"></u-gap>
							<view class="f26 c343 bold textoverflow2">{{item.title}}</view>
							<u-gap height="5"></u-gap>
							<view class="flex">
								<u-icon name="heart-fill" size="16"></u-icon>
								<text class="f24 c999 ml10">{{item.likeVolume || 0}}</text>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="flex1 ml10">
				<view class="bgFff list-item mb20 box_shadow" v-for="(item,index) in jiList" :key="index"
					@click="nologinJump('/subpage/travel/workDetail?id='+item.id)">
					<view class="list-img">
						<!-- <u-image :src="api_host + item.coverIcon" mode="widthFix"
							width="100%" height="400rpx" radius="5">
						</u-image> -->
						<image :src="api_host + item.coverIcon" class="pro-img" mode="widthFix"></image>
					</view>
					<view class="p20">
						<!-- 遇见黄石 -->
						<view class="flex user-box" v-if="item.relatedColumn === 3">
							<image class="avatar" :src="api_host + item.encounterUser.userAvatar" mode=""></image>
							<text class="f24 c343 ml10 nick-name">{{item.encounterUser.nickName}}</text>
						</view>
						<!-- 其他模块 -->
						<view class="flex user-box" v-else>
							<image class="avatar" :src="api_host + item.user.userAvatar" mode=""></image>
							<text class="f24 c343 ml10 nick-name">{{item.user.userName}}</text>
						</view>
						<u-gap height="5"></u-gap>
						<view class="f26 c343 bold textoverflow2">{{item.title}}</view>
						<u-gap height="5"></u-gap>
						<view class="flex">
							<u-icon name="heart-fill" size="16"></u-icon>
							<text class="f24 c999 ml10">{{item.likeVolume || 0}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {} from '@/common/api.js'
	export default {
		name: '',
		props: {
			dataArray: {
				type: Array,
				default: []
			},
			draft: {
				type: Boolean,
				default: false
			}
		},
		data() {
			return {
				ouList: [],
				jiList: []
			}
		},
		onLoad(option) {

		},
		created() {
			this.getList()
		},
		watch: {
			dataArray(newval, oldval) {
				if (newval != oldval) {
					this.getList()
				}
			}
		},
		methods: {
			getList() {
				for (var i = 0; i < this.dataArray.length; i++) {
					if (i % 2 == 0) {
						this.ouList.push(this.dataArray[i])
						let tempObject = {}
						this.ouList = this.ouList.reduce((item, next) => {
							// item为没有重复id的数组，next为当前对象
							tempObject[next.id] ? '' : (tempObject[next.id] = true && item.push(next));
							return item;
						}, [])
					} else {
						this.jiList.push(this.dataArray[i])
						let tempObject = {}
						this.jiList = this.jiList.reduce((item, next) => {
							// item为没有重复id的数组，next为当前对象
							tempObject[next.id] ? '' : (tempObject[next.id] = true && item.push(next));
							return item;
						}, [])
					}
				}
			}
		}
	}
</script>

<style lang="scss">
	.list-item {
		border-radius: 50rpx;

		.list-img {
			width: 100%;
			max-height: 450rpx;
			overflow: hidden;
			border-radius: 50rpx 50rpx 50rpx 0;

			.pro-img {
				width: 100%;
				min-height: 300rpx;
			}
		}

		.user-box {
			margin-top: -80rpx;
			align-items: flex-end;
		}

		.avatar {
			width: 100rpx;
			height: 100rpx;
			margin-top: -20rpx;
			border-radius: 50% 50% 50% 0;
			border: 3px solid #fff;
			background-color: #fff;
		}

		.nick-name {
			margin-top: 60rpx;
		}

		.draft_box {
			position: absolute;
			top: 0;
			left: 0;
			bottom: 0;
			right: 0;
			width: 100%;
			height: 100%;
			background-color: rgba(#000, 0.7);
			border-radius: 50rpx 50rpx 50rpx 0;
		}
	}
</style>